import { defineStore } from 'pinia'

interface System {
	location : Object | null, // 定位信息
	mapConfig : any,
}

const useSystemStore = defineStore('system', {
	state: () : System => {
		return {
			location: null,
			mapConfig: {
				is_open: 1,
				valid_time: 0
			},
		}
	},
	actions: {
		// 获取初始化数据信息
		getInitFn(callback : any) {
			console.log(2222222)

			this.mapConfig.is_open = 1;
			this.mapConfig.valid_time = 3000;
		},
		setLocation(value : any) {
			var date = new Date();
			date.setSeconds(60 * this.mapConfig.valid_time);
			value.valid_time = date.getTime() / 1000; // 定位信息 5分钟内有效，过期后将重新获取定位信息
			this.location = value;
			uni.setStorageSync('location', value); // 初始化数据调用
		}
	}
})

export default useSystemStore